package com.zhang.modules.auth.rep;

import com.zhang.common.jpa.rep.BaseRep;
import com.zhang.modules.auth.eneity.Permission;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Repository
public interface PermissionRep extends BaseRep<Permission, String> {


    @Query(value = "select * from sys_acl_permission p " +
            "where p.id in(select permission_id from sys_acl_role_permission rp where rp.role_id = :roleId)",nativeQuery = true)
    List<Permission> findAllByRoleId(@Param("roleId")String roleId);


    @Modifying
    @Transactional
    long deleteByIdNotNull();




}